package com.laiketui.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gexin.fastjson.JSON;
import com.laiketui.common.mapper.AdminModelMapper;
import com.laiketui.core.common.SplitUtils;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.core.utils.help.DataSerializeHelp;
import com.laiketui.core.utils.help.SpringHelper;
import com.laiketui.domain.lktconst.ErrorCode;
import com.laiketui.domain.mch.AdminModel;
import com.laiketui.domain.user.User;
import com.laiketui.order.api.dto.*;
import com.laiketui.order.api.enums.*;
import com.laiketui.order.api.page.MyPage;
import com.laiketui.order.api.params.mch.*;
import com.laiketui.order.common.RedissonLock;
import com.laiketui.order.domain.Order;
import com.laiketui.order.domain.OrderDetail;
import com.laiketui.order.domain.OrderMessage;
import com.laiketui.order.domain.OrderParent;
import com.laiketui.order.mapstruct.OrderDetailMapstructMapper;
import com.laiketui.order.mapstruct.OrderMapstructMapper;
import com.laiketui.order.mapstruct.OrderMessageMapstructMapper;
import com.laiketui.order.service.*;
import com.laiketui.order.utils.DataMasking;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.*;
import java.util.stream.Collectors;

@Service
@Slf4j
public class MchOrderServiceImpl implements MchOrderService {


    @Autowired
    private OrderService orderService;
    @Autowired
    private WarehouseService warehouseService;
    @Autowired
    private OrderParentService orderParentService;

    @Autowired
    private OrderMessageService orderMessageService;
    @Autowired
    private OrderDetailService orderDetailService;
    @Autowired
    private OrderProcessService orderProcessService;
    @Autowired
    AdminModelMapper adminModelMapper;
    @Autowired
    private RedissonLock redissonLock;

    @Override
    public MyPage<MchOrderDTO> getOrderList(MchOrderListParams params) {
        Page<Order> pageInfo = new Page<>(params.getCurrent(), params.getPageSize());
        LambdaQueryWrapper<Order> wrapper=new LambdaQueryWrapper<>();

        wrapper.eq(Order::getMchId, params.getMchId());
        if(Objects.isNull(params.getStatus())){
            List<Integer> statusList = new ArrayList<>();
            statusList.add(OrderStatusEnum.WAIT_CHECK.getCode());
            statusList.add(OrderStatusEnum.WAIT_SEND.getCode());
            statusList.add(OrderStatusEnum.WAIT_RECEIVE.getCode());
            statusList.add(OrderStatusEnum.FINISH.getCode());
            wrapper.in(Order::getStatus, statusList);
        }else{
            wrapper.eq(Order::getStatus, params.getStatus());
        }
        if(StringUtils.isNotBlank(params.getKeyWords())){
            wrapper.like(Order::getKeyWords, params.getKeyWords());
        }
        if(StringUtils.isNotBlank(params.getOrderNo())){
            wrapper.like(Order::getOrderNo, params.getOrderNo());
        }
        wrapper.orderByDesc(Order::getOrderNo);
        IPage<Order> page = orderService.page(pageInfo,wrapper);
        List<Order> records = page.getRecords();
        List<MchOrderDTO> dtOs = OrderMapstructMapper.INSTANCE.toMchDTOs(records);
        Map<Integer, String> customerNameMap=getCustomerNameMap(records);
//        if(!CollectionUtils.isEmpty(records)){
//            List<String> orderParentNos = dtOs.stream().map(MchOrderDTO::getOrderParentNo).collect(Collectors.toList());
//            List<OrderParent> orderParents= orderParentService.getByOrerParentNoList(orderParentNos);

//        }
        //获取仓库的地址
        WarehouseDTO warehouse = warehouseService.getWarehouse();
        String  channel = warehouseService.getChannel();
        dtOs.forEach(item->{
            String customerName = customerNameMap.get(item.getCustomerId());
            convertMchOrderDTO(item, warehouse, channel, customerName);
        });

        return new MyPage<MchOrderDTO>(page.getCurrent(), page.getSize(), page.getTotal(), dtOs);
    }

    private static void convertMchOrderDTO(MchOrderDTO item, WarehouseDTO warehouse, String channel, String customerName) {
        item.setWarehouseDTO(warehouse);
        item.setChannel(channel);
        item.setName(item.getName());
//        item.setName(DataMasking.maskString(item.getName(),1));
        if(StringUtils.isNotBlank(customerName)){
            item.setCustomerName(customerName);
        }
        item.setSourceName(OrderSourceEnum.getDecByCode(item.getSource()));
        setOrderStatusRemark(item);
    }

    private Map<Integer, String> getCustomerNameMap(List<Order> records) {
        HashMap<Integer, String> customerNameMap = new HashMap<>();
        customerNameMap.put(null,"Lisa");
        List<Integer> customerIds = records.stream().map(Order::getCustomerId).collect(Collectors.toList());
       if(!CollectionUtils.isEmpty(customerIds)){
           Example example = new Example(AdminModel.class);
           Example.Criteria criteria = example.createCriteria();
           criteria.andIn("id", customerIds);
           List<AdminModel> adminModels = adminModelMapper.selectByExample(example);

           for (AdminModel adminModel : adminModels) {
               customerNameMap.put(adminModel.getId(),adminModel.getReal_name());
           }
       }

        return customerNameMap;
    }

    @Transactional
    @Override
    public String confirm(MchOrderConfirmParams params) {
        Order order = new Order();
        order.setOrderNo(params.getOrderNo());
        order.setEstimatedDeliveryTime(params.getEstimatedDeliveryTime());
        order.setUpdateBy(params.getUserId().toString());
        order.setStatus(OrderStatusEnum.WAIT_SEND.getCode());
        Date now=new Date();
        order.setUpdateTime(now);
        if(StringUtils.isNotBlank(params.getRemark())){
            order.setMchRemark(params.getRemark());
        }
        LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Order::getOrderNo, params.getOrderNo());
        wrapper.eq(Order::getStatus, OrderStatusEnum.WAIT_CHECK.getCode());
        boolean update = orderService.update(order, wrapper);
        if(!update){
            throw new LaiKeAPIException("更新失败");
        }
        //将状态全部更新为备货中
        orderDetailService.confirmByOrderNo(params.getOrderNo(),params.getUserId());
        order=orderService.findByOrderNo(params.getOrderNo());
        //插入跟单信息
        orderMessageService.addOrderMessage(params.getOrderNo(), params.getUserId(), OrderMessageTypeEnum.ORDER_READY.getDesc(), OrderStatusEnum.WAIT_CHECK.getCode(),order.getOrderParentNo(),"",params.getRemark(),OrderMessageTypeEnum.ORDER_READY,getFactoryCustomerName());
        //更新预计发货时间
        orderProcessService.updateEstimatedDeliveryTime(order.getOrderParentNo(), params.getEstimatedDeliveryTime());
        return params.getOrderNo();
    }

    private String getFactoryCustomerName() {
        return "工厂跟单员";
    }

    @Override
    public MchOrderDTO info(MchOrderInfoParams params) {
        Order order = orderService.findByOrderNo(params.getOrderNo());
        if(!order.getMchId().equals(params.getMchId())){
            throw new LaiKeAPIException("没有权限");
        }
        MchOrderDTO mchDTO = OrderMapstructMapper.INSTANCE.toMchDTO(order);
        List<OrderDetail>details=orderDetailService.findByOrderNo(params.getOrderNo());
        List<OrderDetailDTO> dtOs = OrderDetailMapstructMapper.INSTANCE.toDTOs(details);
        mchDTO.setDetails(dtOs);

        boolean needQualityInspection = warehouseService.getNeedQualityInspection(mchDTO.getMchId());
        //设置之间状态以及质检描述
        setQualityInspection(needQualityInspection, mchDTO, details);

        List<Order> orders = new ArrayList<>();
        orders.add(order);
        Map<Integer, String> customerNameMap=getCustomerNameMap(orders);

        String customerName = customerNameMap.get(order.getCustomerId());
        //获取仓库
        WarehouseDTO warehouse = warehouseService.getWarehouse();
        //获取渠道
        String channel = warehouseService.getChannel();
        //增加转换信息
        convertMchOrderDTO(mchDTO, warehouse, channel, customerName);

        List<OrderMessage> messages=orderMessageService.listByOrderNo(order.getOrderNo());
        List<OrderMessageDTO> dtoMessages = OrderMessageMapstructMapper.INSTANCE.toDTOs(messages);
        mchDTO.setMessages(dtoMessages);

        //发货单图片
        List<OrderMessageDTO> messageDTOS = dtoMessages.stream().filter((item) -> OrderMessageTypeEnum.CONFIRM_RECIEVE.getCode()
                .equals(item.getMessageType())).sorted(Comparator.comparing(OrderMessageDTO::getCreateTime).reversed())
                .collect(Collectors.toList());
        if(messageDTOS.size() > 0){
            mchDTO.setSendPhoto(messageDTOS.get(0).getPhoto());
        }
        return mchDTO;
    }

    @Override
    public String ready(MchOrderDetailReadyParams params) {
        if(StringUtils.isBlank(params.getDetailNos())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"请选择商品");
        }
        List<String> detailNoList = Arrays.asList(params.getDetailNos().split(SplitUtils.DH));
        if(CollectionUtils.isEmpty(detailNoList)){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"请选择商品");
        }
        params.setDetailNoList(detailNoList);

        String orderNo = params.getOrderNo();
        Order order = orderService.findByOrderNo(orderNo);
        if(!OrderStatusEnum.WAIT_SEND.getCode().equals(order.getStatus())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"订单状态错误");
        }
        String orderKey = orderService.getOrderKey(orderNo);
        redissonLock.lock(orderKey);
        try{
            MchOrderServiceImpl mchOrderService = SpringHelper.getBeanInfo(this.getClass());
            return mchOrderService.readyTransactional(params);
        }finally {
            redissonLock.unlock(orderKey);
        }

    }

    @Override
    public String send(MchOrderSendParams params) {
        String orderNo = params.getOrderNo();
        Order order = orderService.findByOrderNo(orderNo);
        if(!OrderStatusEnum.WAIT_RECEIVE.getCode().equals(order.getStatus())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"订单状态错误");
        }
        if(!ShipmentTypeEnum.SHIPMENT_YES.getCode().equals(order.getShipmentType())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"请先安排发货");
        }
        List<OrderDetail> list = getWaitCheckOrderDetails(orderNo);
        if(!CollectionUtils.isEmpty(list)){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"存在备货中的商品");
        }
        String orderKey = orderService.getOrderKey(orderNo);
        redissonLock.lock(orderKey);
        try{
            MchOrderServiceImpl mchOrderService = SpringHelper.getBeanInfo(this.getClass());
            return mchOrderService.sendTransactional(params);
        }finally {
            redissonLock.unlock(orderKey);
        }
    }

    @Override
    public String revoke(MchOrderDetailReadyParams params) {
        if(StringUtils.isBlank(params.getDetailNos())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"请选择商品");
        }
        List<String> detailNoList = Arrays.asList(params.getDetailNos().split(SplitUtils.DH));
        if(CollectionUtils.isEmpty(detailNoList)){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"请选择商品");
        }
        params.setDetailNoList(detailNoList);

        String orderNo = params.getOrderNo();
        Order order = orderService.findByOrderNo(orderNo);
        if(!OrderStatusEnum.WAIT_SEND.getCode().equals(order.getStatus()) && !OrderStatusEnum.WAIT_RECEIVE.getCode().equals(order.getStatus())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"订单状态错误");
        }
        String orderKey = orderService.getOrderKey(orderNo);
        redissonLock.lock(orderKey);
        try{
            MchOrderServiceImpl mchOrderService = SpringHelper.getBeanInfo(this.getClass());
            return mchOrderService.revokeTransactional(params);
        }finally {
            redissonLock.unlock(orderKey);
        }
    }

    @Override
    public MchPrintTagInfoDTO printTagInfo(MchOrderDetailParams params) {
        OrderDetail orderDetail= orderDetailService.findByOrderDetailNo(params.getDetailNo());
        MchPrintTagInfoDTO dto = new MchPrintTagInfoDTO();
        dto.setAttribute(DataSerializeHelp.getAttributeStr(orderDetail.getAttribute()));
        dto.setWarehouseDTO(warehouseService.getWarehouse());
        dto.setBrandName(orderDetail.getBrandName());
        dto.setProductCode(orderDetail.getProductCode());
        dto.setMarque(orderDetail.getMarque());
        dto.setProductName(orderDetail.getProductName());


        OrderParent orderParent = orderParentService.getOrderParent(orderDetail.getOrderParentNo());
        dto.setRemark(orderParent.getRemark());
        dto.setName(DataMasking.maskString(orderParent.getName(),1));

        orderMessageService.addOrderMessage(orderDetail.getOrderNo(), params.getUserId(), "工厂打印标签  商品编码："+dto.getProductCode(), OrderStatusEnum.FINISH.getCode(),orderDetail.getOrderParentNo(),"","",OrderMessageTypeEnum.PRINT_TAG,getFactoryCustomerName());
        return dto;
    }

    @Override
    public String sendUpdate(MchOrderSendParams params) {
        String orderNo = params.getOrderNo();
        Order order = orderService.findByOrderNo(orderNo);
        orderMessageService.addOrderMessage(orderNo, params.getUserId(), OrderMessageTypeEnum.CONFIRM_RECIEVE.getDesc(), OrderStatusEnum.FINISH.getCode(),order.getOrderParentNo(),params.getPhoto(),params.getRemark(),OrderMessageTypeEnum.CONFIRM_RECIEVE,getFactoryCustomerName());;
        return orderNo;
    }

    @Override
    public String shipment(MchOrderInfoParams params) {
        String orderNo = params.getOrderNo();
        Order order=new Order();
        Date date = new Date();
        order.setUpdateTime(date);
        order.setUpdateBy(params.getUserId());
        order.setShipmentTime(date);
        order.setShipmentType(ShipmentTypeEnum.SHIPMENT_YES.getCode());
        orderService.updateByOrderNo(order, orderNo);
        orderMessageService.addOrderMessage(orderNo, params.getUserId(), OrderMessageTypeEnum.ORDER_RECEIVE.getDesc(), OrderStatusEnum.WAIT_RECEIVE.getCode(),order.getOrderParentNo(),"","",OrderMessageTypeEnum.ORDER_RECEIVE,getFactoryCustomerName());;
        return orderNo;
    }

    @Override
    public String shipmentCancel(MchOrderInfoParams params) {
        String orderNo = params.getOrderNo();
        Order order=new Order();
        Date date = new Date();
        order.setUpdateTime(date);
        order.setUpdateBy(params.getUserId());
        order.setShipmentTime(null);
        order.setShipmentType(ShipmentTypeEnum.SHIPMENT_NO.getCode());
        orderService.updateByOrderNo(order, orderNo);
        orderMessageService.addOrderMessage(orderNo, params.getUserId(), OrderMessageTypeEnum.ORDER_RECEIVE_CANCEL.getDesc(), OrderStatusEnum.WAIT_RECEIVE.getCode(),order.getOrderParentNo(),"","",OrderMessageTypeEnum.ORDER_RECEIVE_CANCEL,getFactoryCustomerName());;
        return orderNo;
    }

    public String revokeTransactional(MchOrderDetailReadyParams params) {
        Order order = orderService.findByOrderNo(params.getOrderNo());
        if(!OrderStatusEnum.WAIT_SEND.getCode().equals(order.getStatus())  && !OrderStatusEnum.WAIT_RECEIVE.getCode().equals(order.getStatus())){
            throw new LaiKeAPIException("订单状态错误");
        }
        LambdaQueryWrapper<OrderDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(OrderDetail::getDetailNo, params.getDetailNoList());
        OrderDetail detail = new OrderDetail();
        detail.setStatus(OrderDetailEnum.WAIT_CHECK.getCode());
        detail.setUpdateBy(params.getUserId());
        Date now = new Date();
        detail.setStockingTime(now);
        detail.setUpdateTime(now);
        orderDetailService.update(detail, wrapper);

        List<String> detailNoList = params.getDetailNoList();
        List<OrderDetail> list = getOrderDetails(detailNoList);

        //订单改成待发货
        Order updateOrder = new Order();
        order.setStatus(OrderStatusEnum.WAIT_SEND.getCode());
        order.setUpdateBy(params.getUserId());
        order.setUpdateTime(now);
        String orderNo = order.getOrderNo();
        orderService.updateByOrderNo(order, orderNo);
        //添加记录
        orderMessageService.addOrderMessage(orderNo, params.getUserId(), OrderMessageTypeEnum.ORDER_REVOKE.getDesc(), OrderStatusEnum.WAIT_SEND.getCode(),order.getOrderParentNo(),"",
                JSON.toJSONString(list), OrderMessageTypeEnum.ORDER_REVOKE,getFactoryCustomerName());
        return params.getOrderNo();
    }

    public List<OrderDetail> getOrderDetails( List<String> detailNoList) {
        LambdaQueryWrapper<OrderDetail> wrapper;
        wrapper = new LambdaQueryWrapper<>();
        wrapper.select(OrderDetail::getDetailNo, OrderDetail::getProductName, OrderDetail::getProductCode, OrderDetail::getNum,OrderDetail::getBomNum,OrderDetail::getSkuId,OrderDetail::getProductId);
        wrapper.in(OrderDetail::getDetailNo, detailNoList);
        List<OrderDetail> list = orderDetailService.list(wrapper);
        return list;
    }

    private List<OrderDetail> getWaitCheckOrderDetails(String orderNo) {
        LambdaQueryWrapper<OrderDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(OrderDetail::getOrderNo, orderNo)
                .eq(OrderDetail::getStatus, OrderDetailEnum.WAIT_CHECK.getCode())
                .eq(OrderDetail::getDeleted, DelFlagEnum.NORMAL.getCode());
        List<OrderDetail> list = orderDetailService.list(wrapper);
        return list;
    }

    @Transactional
    public String sendTransactional(MchOrderSendParams params) {
        String orderNo = params.getOrderNo();
        Order order = orderService.findByOrderNo(orderNo);
        if(!OrderStatusEnum.WAIT_RECEIVE.getCode().equals(order.getStatus())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"订单状态错误");
        }
        if(!ShipmentTypeEnum.SHIPMENT_YES.getCode().equals(order.getShipmentType())){
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW,"请先安排发货");
        }
        //更新子单状态
        orderService.updateStatusFinish(orderNo,params.getUserId());
        log.info("完成子单,更新子单状态完成:{}",orderNo);
        orderDetailService.updateStatusFinish(orderNo,params.getUserId());
        log.info("完成子单,更新订单子项完成:{}",orderNo);
        boolean update = orderProcessService.finishOrderParent(order.getOrderParentNo(),orderNo,params.getUserId());
        log.info("完成子单,更新母单状态:{} 是否更新母单状态:{}",orderNo,update);
        orderMessageService.addOrderMessage(orderNo, params.getUserId(), OrderMessageTypeEnum.CONFIRM_RECIEVE.getDesc(), OrderStatusEnum.FINISH.getCode(),order.getOrderParentNo(),params.getPhoto(),params.getRemark(),OrderMessageTypeEnum.CONFIRM_RECIEVE,getFactoryCustomerName());
        log.info("完成子单,添加消息完成:{}",orderNo);
        return orderNo;
    }

    @Transactional
    public String readyTransactional(MchOrderDetailReadyParams params) {
        Order order = orderService.findByOrderNo(params.getOrderNo());
        if(!OrderStatusEnum.WAIT_SEND.getCode().equals(order.getStatus())){
            throw new LaiKeAPIException("订单状态错误");
        }
        LambdaQueryWrapper<OrderDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(OrderDetail::getDetailNo, params.getDetailNoList());
        OrderDetail detail = new OrderDetail();
        detail.setStatus(OrderDetailEnum.WAIT_SEND.getCode());
        detail.setUpdateBy(params.getUserId());
        Date now = new Date();
        detail.setStockingTime(now);
        detail.setUpdateTime(now);
        orderDetailService.update(detail, wrapper);

        wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(OrderDetail::getOrderNo, params.getOrderNo())
                .eq(OrderDetail::getStatus, OrderDetailEnum.WAIT_CHECK.getCode())
                .eq(OrderDetail::getDeleted, DelFlagEnum.NORMAL.getCode());
       List<OrderDetail> notStockingDetails = orderDetailService.list(wrapper);
        Iterator<OrderDetail> iterator = notStockingDetails.iterator();
        while (iterator.hasNext()){
            OrderDetail tmpDetail = iterator.next();
            if(params.getDetailNoList().contains(tmpDetail.getDetailNo())){
                iterator.remove();
            }
        }
        String orderNo = order.getOrderNo();
        if(CollectionUtils.isEmpty(notStockingDetails)){
            //如果已经全部备货成功,订单要改成可发货
            Order updateOrder = new Order();
            updateOrder.setStatus(OrderStatusEnum.WAIT_RECEIVE.getCode());
            updateOrder.setUpdateBy(params.getUserId());
            updateOrder.setUpdateTime(now);

            orderService.updateByOrderNo(updateOrder, orderNo);
        }
        List<String> detailNoList = params.getDetailNoList();
        List<OrderDetail> list = getOrderDetails(detailNoList);
        //添加记录
        orderMessageService.addOrderMessage(orderNo, params.getUserId(), OrderMessageTypeEnum.ORDER_READY.getDesc(), OrderStatusEnum.WAIT_RECEIVE.getCode(),order.getOrderParentNo(),"",
                JSON.toJSONString(list),OrderMessageTypeEnum.ORDER_READY,getFactoryCustomerName());
        return params.getOrderNo();
    }


    private static void setQualityInspection(boolean needQualityInspection, MchOrderDTO mchDTO, List<OrderDetail> details) {
        if(needQualityInspection){
            mchDTO.setIsNeedQualityInspection(1);
            boolean qualityInspection = true;//已质检
            for (OrderDetail item : details) {
                if(QualityInspectionEnum.WAIT_INSPECTION.getCode().equals(item.getQualityInspection())){
                    qualityInspection=false;
                    break;
                }
            }
            if(qualityInspection){
                mchDTO.setQualityInspectionRemark("是-"+QualityInspectionEnum.INSPECTION_PASS.getDesc());
            }else{
                mchDTO.setQualityInspectionRemark("是-"+QualityInspectionEnum.WAIT_INSPECTION.getDesc());
            }

        }else{
            mchDTO.setIsNeedQualityInspection(0);
            mchDTO.setQualityInspectionRemark("否");
        }
    }


    public static void setOrderStatusRemark(MchOrderDTO mchOrderDTO){
        if(OrderStatusEnum.WAIT_PAY.getCode().equals(mchOrderDTO.getStatus())){
            mchOrderDTO.setStatusRemark(OrderStatusEnum.WAIT_PAY.getDesc());
        }else if(OrderStatusEnum.WAIT_CHECK.getCode().equals(mchOrderDTO.getStatus())){
            mchOrderDTO.setStatusRemark("待填写预计发货时间");
        }else if(OrderStatusEnum.WAIT_SEND.getCode().equals(mchOrderDTO.getStatus())){
            mchOrderDTO.setStatusRemark(OrderStatusEnum.WAIT_SEND.getDesc());
        }else if(OrderStatusEnum.WAIT_RECEIVE.getCode().equals(mchOrderDTO.getStatus())){
            mchOrderDTO.setStatusRemark(OrderStatusEnum.WAIT_RECEIVE.getDesc());
        }else if(OrderStatusEnum.FINISH.getCode().equals(mchOrderDTO.getStatus())){
            mchOrderDTO.setStatusRemark(OrderStatusEnum.FINISH.getDesc());
        }
    }
}
